// pages/member/activityOrder.js
var req = require('../../interfaceImpl.js');
var config = require('../../interfaceConfig.js');
var app = getApp();
const strAppCode = config.SmallApp;
var page = 1;
var pagesize = 5;
var OrderType = 0;
var reqgetOrderSign = "";
var goodlist = [];
var imgpath = config.imgHost;
var imgpath2 = config.imgHost2;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgpath: imgpath,
    imgpath2: imgpath2
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var getOrderSign = "strAppCode=" + strAppCode + "page=" + page + "pagesize=" + pagesize + "OrderSource=1" + "StartDate=" + "EndDate=" + "OrderType=" + OrderType;
    return req.GetSignStr(getOrderSign).then(res => {
      reqgetOrderSign = res.data.data;
    }).then(() => {
      return req.GetAllOrderList(strAppCode, page, pagesize, "1", "", "", OrderType, reqgetOrderSign, app.globalData.token).then(res => {
        //  TODO 请求所有订单
        console.log(res)
        goodlist = res.data.Result;
        this.setData({ goodlist })
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  viewDetail: function (e) {
    console.log('详情')
    console.log(e.currentTarget.dataset.pojo)
    if (e.currentTarget.dataset.pojo.FilmName == ""){
      //TODO跳转到卖品详情
      wx.navigateTo({
        url: '../showgooddetail/showgooddetail?pojo=' + JSON.stringify(e.currentTarget.dataset.pojo) + '',
      })
    }
    else if (e.currentTarget.dataset.pojo.FilmName !== ""){
      wx.navigateTo({
        url: '../showdetail/showdetail?pojo=' + JSON.stringify(e.currentTarget.dataset.pojo) + '',
        success: function (res) { },
        fail: function (res) { },
        complete: function (res) { },
      })
    }
  },

  goback: function () {
    wx.showModal({
      title: '提示',
      content: '要返回会员中心么',
      success: function (res) {
        if (res.confirm) {
          wx.switchTab({
            url: '../member/index',
          })
        }
      }
    })
  },
  pay: function (e) {
    console.log('支付')
  }
})